package com.plian.system.dao.sys.orgzation;

import com.plian.Tools.TokenUtil;
import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
@Component
public class OrgzationDao {
    @Resource(name = "daoSupport")
    private DaoSupport dao;
    public void save(PageData pd) throws Exception {
        dao.save("OrgzationMapper.save",pd);
    }

    public void save2(PageData pd) throws Exception {
        dao.save("OrgzationMapper.save2",pd);
    }

    public void  edit(PageData pd) throws Exception {
        dao.update("OrgzationMapper.edit",pd);
    }
    public void editForGzw(PageData pd)throws Exception {
        dao.update("OrgzationMapper.editForGzw",pd);
    }


    public PageData findbyid(String id) throws Exception {
        return (PageData) dao.findForObject("OrgzationMapper.findbyid",id);
    }
    public List<PageData> findbyPid(String id) throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.findbyPid",id);
    }

    public List<PageData> findThirteen() throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.findThirteen",null);
    }
    public List<PageData> findchildbyid(String id) throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.findchildbyid",id);
    }
    public List<PageData> findorgbyidandtype(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.findorgbyidandtype",pd);
    }
    public List<PageData> findUnits(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.findUnits",pd);
    }
    public List<PageData> findGZWUnits() throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.findGZWUnits", null);
    }

    public List<PageData> findGZWUnitsFilterDT() throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.findGZWUnitsFilterDT", null);
    }
    public void del_ids(List<String> ids) throws Exception {
        dao.delete("OrgzationMapper.del_ids",ids);
    }

    /**
     *根据id集合批量修改状态
     * @param ids
     * @throws Exception
     */
    public void edit_del_ids(List<String> ids) throws Exception {
        dao.update("OrgzationMapper.edit_del_ids",ids);
    }
    public List<PageData> list(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.list",pd);
    }
    public List<PageData> listByBasics(PageData pd) throws Exception {

        return (List<PageData>) dao.findForList("OrgzationMapper.listByBasics",pd);
    }
    public List<PageData> listForGzw() throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.listForGzw",null);
    }

    /**
     * 修改状态
     */
    public void refer(PageData pd) throws Exception {
        dao.update("OrgzationMapper.refer",pd);
    }

    /**
     * 批量调整
     * @param pd
     * @throws Exception
     */
    public void adjustment(PageData pd) throws Exception {
        dao.update("OrgzationMapper.adjustment",pd);
    }

    /**
     * 变更记录
     * @param pd
     * @throws Exception
     */
    public void orgrecord(PageData pd) throws Exception {
        dao.update("OrgzationMapper.orgrecord",pd);
    }
    public List<PageData> orgNewDateList(PageData pd) throws Exception {
       return (List<PageData>) dao.findForList("OrgzationMapper.orgNewDateList",pd);
    }

    /**
     * 查询非虚拟节点列表
     * @return
     * @throws Exception
     */
    public List<PageData> listUnFictitious() throws Exception {
       return (List<PageData>) dao.findForList("OrgzationMapper.listUnFictitious",new PageData());
    }

    /**
     * 根据名称匹配
     * @param name
     * @return
     * @throws Exception
     */
    public List<PageData> findByName(String name) throws Exception {
       return (List<PageData>) dao.findForList("OrgzationMapper.findByName",name);
    }

    public List<String> getFillingOrg(String sql) throws Exception{
        PageData pd = new PageData();
        pd.put("sql", sql);
        return (List<String>) dao.findForList("OrgzationMapper.getFillingOrg", pd);
    }

    public List<PageData> findGZWAndUnits() throws Exception {
        return (List<PageData>) dao.findForList("OrgzationMapper.findGZWAndUnits", null);
    }

    /**
     * 获取国资委下面的一级集团名称
     * @return
     * @throws Exception
     */
    public List<PageData> getGroupOrgList() throws Exception{
        return (List<PageData>) dao.findForList("OrgzationMapper.getGroupOrgList", null);
    }

    public PageData findRepeatName(String name) throws Exception {
        return (PageData) dao.findForObject("OrgzationMapper.findRepeatName",name);
    }
}
